package com.sc.nft.admin.controller;

import cn.hutool.core.util.StrUtil;
import com.sc.nft.admin.request.IdConfirmRequest;
import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.dto.AddWorkRoomDTO;
import com.sc.nft.entity.dto.UserWorkRoomPageDTO;
import com.sc.nft.entity.vo.UserWorkRoomPageVO;
import com.sc.nft.entity.vo.WorkRoomExportVO;
import com.sc.nft.service.UserWorkRoomService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * (UserWorkRoom)表控制层
 *
 * @author wwc
 * @since 2023-07-18 17:25:52
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/userWorkRoom")
@Api(tags = "社区网点")
public class UserWorkRoomController {

    /**
     * 服务对象
     */
    private final UserWorkRoomService userWorkRoomService;

    @ApiOperation(value = "取消社区网点", notes = "取消社区网点", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/cancelCommunityOutlets", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result cancelCommunityOutlets(@Valid @RequestBody IdConfirmRequest request) {
        return Result.success(userWorkRoomService.cancelCommunityOutlets(request.getId()));
    }

    @ApiOperation(value = "添加社区网点", notes = "取消社区网点", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/addWorkRoom", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result addWorkRoom(@Validated @RequestBody AddWorkRoomDTO addWorkRoomDTO) {
        userWorkRoomService.addWorkRoom(addWorkRoomDTO);
        return Result.success();
    }

    @ApiOperation(value = "分页列表", notes = "分页列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<UserWorkRoomPageVO> page(@RequestBody UserWorkRoomPageDTO userWorkRoomPageDTO) {
        return PageResult.success(userWorkRoomService.page(userWorkRoomPageDTO));
    }

    @ApiOperation(value = "社区网点导出", notes = "社区网点导出", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/workRoomExport", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<List<WorkRoomExportVO>> workRoomExport() {
        return Result.success(userWorkRoomService.workRoomExport());
    }
}
